import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    monacoEditorPlugin.default({
    })
  ],

  resolve: {
    //设置路径别名
    alias: {
      "@": resolve(__dirname, "src/"),
      "views/*": resolve(__dirname, "src/views"),
      "@icons": resolve(__dirname, "src/assets/svg/"),
      "components/*": resolve(__dirname, "src/components"),
      "*": resolve(""),
    },
  },

  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true, // 支持内联 JavaScript
      },
    },
  },
  server: {
    // 服务器默认端口是8080，前台8081，后台8082，装修8083，所以需要代理
    port: 8083,
    host: "0.0.0.0",
    // 自动打开浏览器
    open: false,
    proxy: {
      // 设置代理
      "/precodegen": {
        target: "http://yykj.caihongy.cn/",
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/nodejsx4756827/, ""),
      },
    },
  },
  // 打包后的文件引入路径 由/assets，改为./assets
  base: "",
  build: {
    manifest: true,
    rollupOptions: {
      output: {
        sourcemap: false,
      },
    },
  },
})
